POV-Ray : Newsgroups : povray.general : #local access : #local access Server Time
8 Aug 2024 04:03:55 EDT (-0400)
  #local access  
From: Rune
Date: 1 Mar 2001 16:07:24
Message: <3a9eba0c@news.povray.org>
Consider the code below:

box{x,x}
#macro Mother(Input)
   #local Var = Input;
   Child()
#end
#macro Child()
   #local Var = Var+1; // line 7
   Var
#end
#declare Number = Mother(1);
#debug str(Number,0,0)

It generates an error at line 7.
But if the Child macro is changed to:

#macro Child()
   #local Var2 = Var+1; // line 7
   Var2
#end

The code works fine. That is, the mother variable "Var" is only accessible
if it is not currently being assigned at a lower level. But I thought a
variable was not supposed to interfere with anything before the assignment
was completed (semi-colon reached) ?  Or is it?

On an unrelated note: Isn't there any way I can make the child macro handle
and update a variable created in the mother macro, besides making the
variable global? I'm afraid not?

Rune
--
\ Include files, tutorials, 3D images, raytracing jokes,
/ The POV Desktop Theme, and The POV-Ray Logo Contest can
\ all be found at http://rsj.mobilixnet.dk (updated January 28)
/ Also visit http://www.povrayusers.org


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.